package Form;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

import javax.swing.DefaultListModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.ListSelectionModel;
import javax.swing.border.LineBorder;
import javax.swing.JButton;

/**
 * 
 * @author LM.LOVE
 */
public class WeatherStationForm extends javax.swing.JFrame {
	private static final long serialVersionUID = 1L;

	/**
	 * Creates new form WeatherStationForm
	 */
	public WeatherStationForm(String stationID) {
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosed(WindowEvent arg0) {
				weatherSH.getWeatherStation().setAdminRole(0);
				weatherSH.updateDatabaseWeatherStation();
			}
		});
		initComponents(stationID);

		weatherSH = new WeatherStationHandling(stationID);
		doTaskUpdate();
		tPane.setEnabledAt(3, false);
		// Xac thuc cac thanh phan khoi tao
		this.validate();
	}

	/*
	 * Ham nay de hien thi thong tin thu thap duoc len man hinh WeatherStation
	 */
	public void showOnForm() {
		lblBatteryInPercentage.setText(Integer.toString(weatherSH
				.getWeatherStation().getBattery()));
		if (weatherSH.getWeatherStation().getBattery() >= 50
				&& weatherSH.getWeatherStation().getBattery() <= 100) {
			lblBatteryStatus.setText("Good");
		} else {
			lblBatteryStatus.setText("Bad");
		}
		lblOnOffValue
				.setText((weatherSH.getWeatherStation().getStatus() == 0) ? "Off"
						: "On");
		lblConnectionStatus.setText((weatherSH.getWeatherStation()
				.getConnection() == 0) ? "Bad" : "Good");

		if (weatherSH.getWeatherSC() != null) {
			lblWSValue.setText(weatherSH.getWeatherSC().getWindSpeed()
					.toString());
			lblABValue.setText(weatherSH.getWeatherSC().getAirBlast()
					.toString());
			lblRainfallValue.setText(weatherSH.getWeatherSC()
					.getRainfallIn24h().toString());
			lblAMValue.setText(weatherSH.getWeatherSC().getAirMoisture()
					.toString());
			lblGMValue.setText(weatherSH.getWeatherSC().getGroundMoisture()
					.toString());
			lblAPValue.setText(weatherSH.getWeatherSC().getAirPressure()
					.toString());
		}
		/* List<String> lReport = weatherSH.getAllReportValue(); */
		// this.dlmReport = new DefaultListModel<String>();
		if (dlmReport.getSize() != weatherSH.getlReport().size()) {
			dlmReport.removeAllElements();
			for (int i = 0; i < weatherSH.getlReport().size(); i++) {
				dlmReport.addElement("Report " + (i + 1));
			}
			/*
			 * listReport.setModel(dlmReport);
			 * listReportResponse.setModel(dlmReport);
			 */
			this.validate();
		}

	}

	/*
	 * Ham nay dung de reset lai cac component sau khi bi admin chiem quyen Neu
	 * admin chiem quyen thi cac component se bi disable Nguoc lai thi se duoc
	 * release
	 */
	public void refresh() {
		if (weatherSH.getWeatherStation().getAdminRole() == 1) {
			/* tPane.setEnabledAt(0, false); */
			buttonCharge.setEnabled(false);
			buttonRestart.setEnabled(false);
			buttonShutdown.setEnabled(false);
			buttonStart.setEnabled(false);
		} else {
			/* tPane.setEnabledAt(0, true); */
			buttonCharge.setEnabled(true);
			buttonRestart.setEnabled(true);
			buttonShutdown.setEnabled(true);
			buttonStart.setEnabled(true);
		}
		if (lblOnOffValue.getText().equals("Off")) {
			endTaskCollection();
		} else if (lblOnOffValue.getText().equals("On")) {
			doTaskCollection();
		} else {
		}
	}

	/*
	 * Ham nay dung de hien thi cac component admin Khi bi admin chiem quyen se
	 * chay ham nay de hien thi len
	 */
	public void showComponentAdmin() {
		tPane.setEnabledAt(3, true);
		tPane.setEnabledAt(2, false);
		tPane.setEnabledAt(1, false);
	}

	/*
	 * Ham nay dung de thu thap thoi tiet Cu 10s se thu thap 1 lan
	 */
	public void doTaskCollection() {
		if (timer == null) {
			timer = new Timer();
			TimerTask tt = new TimerTask() {
				@Override
				public void run() {
					DefaultListModel<String> dlmDamaged = new DefaultListModel<String>();
					if (weatherSH.readFileInput() == false) {
						List<String> lError = weatherSH.findBug();
						// Neu co loi ma size ==0 => loi doc file
						if (lError.size() == 0) {
							JOptionPane
									.showMessageDialog(null,
											"can't find file input.txt Or the format file isn't in standard form!!!");
							JOptionPane
									.showMessageDialog(
											null,
											"Standard form:(\nBattery:\nConnection:\nOn/Off:\nWindSpeed:\nAirblast:\nRainfallin24h:\nAirMoisture:\nGroundMoisture:\nAirPressure:\n)");
							return;
						}
						//Kiem tra xem bi hu cho nao de gan' vao label
						for (String error : lError) {
							if (error.equals("Air Blast")) {
								lblABStatus.setText("Error");
							} else if (error.equals("Wind Speed")) {
								lblWSStatus.setText("Error");
							} else if (error.equals("Rainfall in 24h")) {
								lblRainfallStatus.setText("Error");
							} else if (error.equals("Air Moisture")) {
								lblAMStatus.setText("Error");
							} else if (error.equals("Ground Moisture")) {
								lblGMStatus.setText("Error");
							} else if (error.equals("Air Pressure")) {
								lblGMStatus.setText("Error");
							}
							dlmDamaged.addElement(error);
							weatherSH.isDamaged(1);
						}
					} else {
						lblABStatus.setText("Good");
						lblWSStatus.setText("Good");
						lblRainfallStatus.setText("Good");
						lblAMStatus.setText("Good");
						lblGMStatus.setText("Good");
						lblGMStatus.setText("Good");
						showOnForm();
					}
					listDamaged.setModel(dlmDamaged);
				}
			};
			timer.schedule(tt, 10000, 10000);
		}
	}

	/*
	 * Ham nay dung de kiem tra xem co bi admin chiem quyen hay khong Cu 2s se
	 * kiem tra 1 lan Ngoai ra ham nay con cap nhat lai list report response
	 */
	public void doTaskUpdate() {
		if (timer2 == null) {
			timer2 = new Timer();
			TimerTask task = new TimerTask() {

				@Override
				public void run() {
					weatherSH.checkControl();
					refresh();
					showOnForm();
				}
			};
			timer2.schedule(task, 1000, 2000);
		}
	}

	/*
	 * Ham nay de ket thuc ham doTaskUpdate()
	 */
	public void endTaskUpdate() {
		if (timer2 != null) {
			timer2.cancel();
			timer2.purge();
			timer2 = null;
		}
	}

	/*
	 * Ham nay dung de ket thuc viec thu thap thoi tiet khi an nut tat may
	 */
	public void endTaskCollection() {
		if (timer != null) {
			timer.cancel();
			timer.purge();
			timer = null;
		}
	}

	private void initComponents(String stationID) {

		tPane = new javax.swing.JTabbedPane();
		informationPanel = new javax.swing.JPanel();
		panelStatus = new javax.swing.JPanel();
		lblOnOff = new javax.swing.JLabel();
		lblBattery = new javax.swing.JLabel();
		lblBatteryStatus = new javax.swing.JLabel();
		lblConnection = new javax.swing.JLabel();
		lblConnectionStatus = new javax.swing.JLabel();
		lblBatteryInPercentage = new javax.swing.JLabel();
		ImageIcon image = new ImageIcon("src\\battery.png");
		lblBatteryImage = new javax.swing.JLabel(image);
		panelManipulation = new javax.swing.JPanel();
		lblStart = new javax.swing.JLabel();
		lblRestart = new javax.swing.JLabel();
		lblShutdown = new javax.swing.JLabel();
		lblChargePin = new javax.swing.JLabel();
		buttonStart = new javax.swing.JButton();
		buttonStart.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent mEvent) {
				if (lblOnOffValue.getText().equals("On")) {
					JOptionPane.showMessageDialog(null,
							"The Station is already started");
				} else {
					lblOnOffValue.setText("On");
					weatherSH.setStatus(1);
					JOptionPane.showMessageDialog(null, "Started Successfully");
					if (!weatherSH.isAdminRole()) {
						doTaskCollection();
					}
				}
			}
		});
		buttonRestart = new javax.swing.JButton();
		buttonRestart.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent mEvent) {
				if (lblOnOffValue.getText().equals("On")) {
					weatherSH.restart();
					showOnForm();
					JOptionPane.showMessageDialog(null, "Restart Successfully");
					if (!weatherSH.isAdminRole()) {
						doTaskCollection();
					}
				} else {
					JOptionPane
							.showMessageDialog(null,
									"The Station is shut down.Please turn on before restarting");
				}
			}
		});
		buttonShutdown = new javax.swing.JButton();
		buttonShutdown.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent mEven) {
				if (lblOnOffValue.getText().equals("On")) {
					lblOnOffValue.setText("Off");
					weatherSH.setStatus(0);
					endTaskCollection();
					JOptionPane
							.showMessageDialog(null, "Shutdown Successfully");

				} else {
					JOptionPane.showMessageDialog(null,
							"The Station is already shutdown");
				}
			}
		});
		buttonCharge = new javax.swing.JButton();
		buttonCharge.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent mEvent) {
				if (lblBatteryInPercentage.getText().equals("100")) {
					JOptionPane.showMessageDialog(null,
							"The Battery's Station is 100%");
				} else {
					lblBatteryInPercentage.setText("100");
					weatherSH.setBattery(100);
					weatherSH.updateDatabaseWeatherStation();
					JOptionPane.showMessageDialog(null, "Charged successfully");
				}
			}
		});
		collectionPanel = new javax.swing.JPanel();
		panelCollected = new javax.swing.JPanel();
		lblWindSpeed = new javax.swing.JLabel();
		lblAirBlast = new javax.swing.JLabel();
		lblRainfall = new javax.swing.JLabel();
		lblAirMoisture = new javax.swing.JLabel();
		lblGroundMoisture = new javax.swing.JLabel();
		lblAirPressure = new javax.swing.JLabel();
		lblWSValue = new javax.swing.JLabel();
		lblABValue = new javax.swing.JLabel();
		lblRainfallValue = new javax.swing.JLabel();
		lblAMValue = new javax.swing.JLabel();
		lblGMValue = new javax.swing.JLabel();
		lblAPValue = new javax.swing.JLabel();
		lblWSUnit = new javax.swing.JLabel();
		lblABUnit = new javax.swing.JLabel();
		lblUnitAB = new javax.swing.JLabel();
		lblAMUnit = new javax.swing.JLabel();
		lblGMUnit = new javax.swing.JLabel();
		lblAPUnit = new javax.swing.JLabel();
		lblABStatus = new javax.swing.JLabel();
		lblABStatus.setForeground(Color.RED);
		lblWSStatus = new javax.swing.JLabel();
		lblWSStatus.setForeground(Color.RED);
		lblAPStatus = new javax.swing.JLabel();
		lblAPStatus.setForeground(Color.RED);
		lblRainfallStatus = new javax.swing.JLabel();
		lblRainfallStatus.setForeground(Color.RED);
		lblAMStatus = new javax.swing.JLabel();
		lblAMStatus.setForeground(Color.RED);
		lblGMStatus = new javax.swing.JLabel();
		lblGMStatus.setForeground(Color.RED);
		lblDateTime = new javax.swing.JLabel();
		panelReport = new javax.swing.JPanel();
		panelSubReport = new javax.swing.JPanel();
		scrollReportStaff = new javax.swing.JScrollPane();
		reportFieldStaff = new javax.swing.JTextArea();
		buttonSend = new javax.swing.JButton();
		buttonSend.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent mEvent) {
				if (!(reportFieldStaff.getText().equals(""))) {
					String damaged = "";
					if (listDamaged.getModel().getSize() != 0) {
						damaged = listDamaged.getModel().toString();
					}
					weatherSH.addReport(reportFieldStaff.getText(), damaged);
					JOptionPane.showMessageDialog(null, "Send successfully");
					reportFieldStaff.setText("");
					showOnForm();
				} else {
					JOptionPane
							.showMessageDialog(null,
									"Please type something here before sending a message");
				}

			}
		});
		scrollListReportResponseStaff = new javax.swing.JScrollPane();
		listReportResponse = new javax.swing.JList<String>();
		dlmReport = new DefaultListModel<>();
		listReportResponse.setModel(dlmReport);
		listReportResponse.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent mEvent) {
				if (listReportResponse.getSelectedIndex() != -1) {
					String valueReport = weatherSH
							.getValueReportResponsed(listReportResponse
									.getSelectedValue());

					reportReponseStaff.setText(valueReport);
				}
			}
		});
		listReportResponse.setVisibleRowCount(10000);
		listReportResponse
				.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		scrollReportResponseStaff = new javax.swing.JScrollPane();
		reportReponseStaff = new javax.swing.JTextArea();
		reportReponseStaff.setLineWrap(true);
		reportReponseStaff.setWrapStyleWord(true);
		panelListDamaged = new javax.swing.JPanel();
		scrollPanelListDamaged = new javax.swing.JScrollPane();
		listDamaged = new javax.swing.JList<String>();
		reportARPanel = new javax.swing.JPanel();
		reportARPanel.setEnabled(false);
		reportStationPanel = new javax.swing.JPanel();
		scrollListReport = new javax.swing.JScrollPane();
		listReport = new javax.swing.JList<String>();
		listReport.setModel(dlmReport);
		listReport.setLayoutOrientation(JList.HORIZONTAL_WRAP);
		listReport.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent mEvent) {
				if (listReport.getSelectedIndex() != -1) {
					String valueReport = weatherSH.getValueReport(listReport
							.getSelectedValue());
					reportFieldAR.setText(valueReport);
				}
			}
		});
		listReport.setVisibleRowCount(10000);
		listReport.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		scrollReportAR = new javax.swing.JScrollPane();
		reportFieldAR = new javax.swing.JTextArea();
		reportFieldAR.setFont(new Font("Arial", Font.BOLD, 18));
		reportFieldAR.setColumns(20);
		reportResponseARPanel = new javax.swing.JPanel();
		scrollReportResponse = new javax.swing.JScrollPane();
		reportResponseAR = new javax.swing.JTextArea();
		sendButton = new javax.swing.JButton();
		sendButton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent mEvent) {
				if (listReport.getSelectedIndex() == -1) {
					JOptionPane.showMessageDialog(null,
							"Please choose report to respond!!!");
					return;
				}
				if (reportResponseAR.getText().equals("")) {
					JOptionPane.showMessageDialog(null,
							"Please type something to respond!!!");
					return;
				}
				weatherSH.addResponsedReport(listReport.getSelectedIndex(),
						reportResponseAR.getText());
				reportResponseAR.setText("");
				JOptionPane
						.showMessageDialog(null, "Responded successfully!!!");
			}
		});
		lblOnOffValue = new javax.swing.JLabel("On/Off");
		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setTitle("Weather Station " + stationID);
		setName("WeatherStationfrm"); // NOI18N
		setPreferredSize(new java.awt.Dimension(540, 550));

		informationPanel.setBorder(javax.swing.BorderFactory
				.createEtchedBorder());

		panelStatus.setBorder(javax.swing.BorderFactory
				.createTitledBorder("Status"));
		panelStatus.setToolTipText("");
		panelStatus.setName(""); // NOI18N

		lblOnOff.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblOnOff.setText("On/Off");

		lblBattery.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblBattery.setText("Battery");

		lblBatteryStatus.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblBatteryStatus.setForeground(new java.awt.Color(255, 0, 0));
		lblBatteryStatus.setText("Good/Bad");

		lblConnection.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblConnection.setText("Connection");

		lblConnectionStatus.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblConnectionStatus.setForeground(new java.awt.Color(255, 0, 0));
		lblConnectionStatus.setText("Connection");

		lblBatteryInPercentage.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblBatteryInPercentage.setText("100%");

		lblBatteryImage.setBorder(new LineBorder(new Color(0, 0, 0), 0));

		javax.swing.GroupLayout lblBatteryImageLayout = new javax.swing.GroupLayout(
				lblBatteryImage);
		lblBatteryImage.setLayout(lblBatteryImageLayout);
		lblBatteryImageLayout.setHorizontalGroup(lblBatteryImageLayout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGap(0, 0, Short.MAX_VALUE));
		lblBatteryImageLayout.setVerticalGroup(lblBatteryImageLayout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGap(0, 0, Short.MAX_VALUE));
		lblOnOffValue.setForeground(Color.RED);
		lblOnOffValue.setFont(new Font("Tahoma", Font.BOLD, 16));

		javax.swing.GroupLayout panelStatusLayout = new javax.swing.GroupLayout(
				panelStatus);
		panelStatusLayout
				.setHorizontalGroup(panelStatusLayout
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								panelStatusLayout
										.createSequentialGroup()
										.addGap(56)
										.addGroup(
												panelStatusLayout
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																panelStatusLayout
																		.createSequentialGroup()
																		.addGroup(
																				panelStatusLayout
																						.createParallelGroup(
																								Alignment.LEADING)
																						.addGroup(
																								panelStatusLayout
																										.createSequentialGroup()
																										.addComponent(
																												lblBattery,
																												GroupLayout.DEFAULT_SIZE,
																												55,
																												Short.MAX_VALUE)
																										.addGap(27))
																						.addGroup(
																								panelStatusLayout
																										.createSequentialGroup()
																										.addComponent(
																												lblOnOff,
																												GroupLayout.DEFAULT_SIZE,
																												52,
																												Short.MAX_VALUE)
																										.addGap(30))
																						.addComponent(
																								lblConnection,
																								GroupLayout.DEFAULT_SIZE,
																								82,
																								Short.MAX_VALUE))
																		.addGap(118))
														.addGroup(
																panelStatusLayout
																		.createSequentialGroup()
																		.addComponent(
																				lblBatteryInPercentage,
																				GroupLayout.DEFAULT_SIZE,
																				126,
																				Short.MAX_VALUE)
																		.addGap(74)))
										.addGroup(
												panelStatusLayout
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																panelStatusLayout
																		.createSequentialGroup()
																		.addGroup(
																				panelStatusLayout
																						.createParallelGroup(
																								Alignment.TRAILING)
																						.addGroup(
																								panelStatusLayout
																										.createSequentialGroup()
																										.addComponent(
																												lblConnectionStatus,
																												GroupLayout.DEFAULT_SIZE,
																												81,
																												Short.MAX_VALUE)
																										.addGap(2))
																						.addGroup(
																								panelStatusLayout
																										.createSequentialGroup()
																										.addGroup(
																												panelStatusLayout
																														.createParallelGroup(
																																Alignment.TRAILING)
																														.addComponent(
																																lblOnOffValue,
																																Alignment.LEADING,
																																GroupLayout.DEFAULT_SIZE,
																																74,
																																Short.MAX_VALUE)
																														.addComponent(
																																lblBatteryStatus,
																																GroupLayout.DEFAULT_SIZE,
																																74,
																																Short.MAX_VALUE))
																										.addGap(9)))
																		.addGap(75))
														.addGroup(
																panelStatusLayout
																		.createSequentialGroup()
																		.addComponent(
																				lblBatteryImage,
																				GroupLayout.PREFERRED_SIZE,
																				42,
																				GroupLayout.PREFERRED_SIZE)
																		.addContainerGap()))));
		panelStatusLayout
				.setVerticalGroup(panelStatusLayout
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								panelStatusLayout
										.createSequentialGroup()
										.addGap(12)
										.addGroup(
												panelStatusLayout
														.createParallelGroup(
																Alignment.BASELINE)
														.addComponent(
																lblOnOff,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblOnOffValue))
										.addPreferredGap(
												ComponentPlacement.UNRELATED)
										.addGroup(
												panelStatusLayout
														.createParallelGroup(
																Alignment.BASELINE)
														.addComponent(
																lblBattery,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblBatteryStatus,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addPreferredGap(
												ComponentPlacement.RELATED)
										.addGroup(
												panelStatusLayout
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																panelStatusLayout
																		.createSequentialGroup()
																		.addComponent(
																				lblBatteryInPercentage,
																				GroupLayout.DEFAULT_SIZE,
																				GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addGap(8))
														.addGroup(
																panelStatusLayout
																		.createSequentialGroup()
																		.addComponent(
																				lblBatteryImage,
																				GroupLayout.DEFAULT_SIZE,
																				19,
																				Short.MAX_VALUE)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)))
										.addGroup(
												panelStatusLayout
														.createParallelGroup(
																Alignment.BASELINE)
														.addComponent(
																lblConnection,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblConnectionStatus))
										.addGap(22)));
		panelStatus.setLayout(panelStatusLayout);

		panelManipulation.setBorder(javax.swing.BorderFactory
				.createTitledBorder("Manipulation"));

		lblStart.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblStart.setText("Start");

		lblRestart.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblRestart.setText("Restart");

		lblShutdown.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblShutdown.setText("Shutdown");

		lblChargePin.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblChargePin.setText("Charge Pin");

		buttonStart.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
		buttonStart.setText("Start");

		buttonRestart.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
		buttonRestart.setText("Restart");

		buttonShutdown.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
		buttonShutdown.setText("Shut down");

		buttonCharge.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
		buttonCharge.setText("Charge");

		javax.swing.GroupLayout panelManipulationLayout = new javax.swing.GroupLayout(
				panelManipulation);
		panelManipulation.setLayout(panelManipulationLayout);
		panelManipulationLayout
				.setHorizontalGroup(panelManipulationLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								panelManipulationLayout
										.createSequentialGroup()
										.addGap(50, 50, 50)
										.addGroup(
												panelManipulationLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																panelManipulationLayout
																		.createSequentialGroup()
																		.addComponent(
																				lblStart,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addGap(40,
																				40,
																				40))
														.addComponent(
																lblChargePin,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addGroup(
																panelManipulationLayout
																		.createSequentialGroup()
																		.addComponent(
																				lblShutdown,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addGap(3,
																				3,
																				3))
														.addGroup(
																panelManipulationLayout
																		.createSequentialGroup()
																		.addComponent(
																				lblRestart,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addGap(24,
																				24,
																				24)))
										.addGap(109, 109, 109)
										.addGroup(
												panelManipulationLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																buttonShutdown,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																buttonCharge,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																buttonRestart,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																buttonStart,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addGap(84, 84, 84)));
		panelManipulationLayout
				.setVerticalGroup(panelManipulationLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								panelManipulationLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												panelManipulationLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																panelManipulationLayout
																		.createSequentialGroup()
																		.addGap(6,
																				6,
																				6)
																		.addComponent(
																				lblStart,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE))
														.addGroup(
																panelManipulationLayout
																		.createSequentialGroup()
																		.addComponent(
																				buttonStart,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addGap(5,
																				5,
																				5)))
										.addGap(18, 18, 18)
										.addGroup(
												panelManipulationLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																panelManipulationLayout
																		.createSequentialGroup()
																		.addGap(6,
																				6,
																				6)
																		.addComponent(
																				lblRestart,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE))
														.addGroup(
																panelManipulationLayout
																		.createSequentialGroup()
																		.addComponent(
																				buttonRestart,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addGap(5,
																				5,
																				5)))
										.addGap(18, 18, 18)
										.addGroup(
												panelManipulationLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																panelManipulationLayout
																		.createSequentialGroup()
																		.addGap(6,
																				6,
																				6)
																		.addComponent(
																				lblShutdown,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE))
														.addGroup(
																panelManipulationLayout
																		.createSequentialGroup()
																		.addComponent(
																				buttonShutdown,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addGap(5,
																				5,
																				5)))
										.addGap(18, 18, 18)
										.addGroup(
												panelManipulationLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addGroup(
																panelManipulationLayout
																		.createSequentialGroup()
																		.addGap(6,
																				6,
																				6)
																		.addComponent(
																				lblChargePin,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE))
														.addComponent(
																buttonCharge,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addGap(23, 23, 23)));

		javax.swing.GroupLayout informationPanelLayout = new javax.swing.GroupLayout(
				informationPanel);
		informationPanelLayout
				.setHorizontalGroup(informationPanelLayout
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								informationPanelLayout
										.createSequentialGroup()
										.addGap(22)
										.addGroup(
												informationPanelLayout
														.createParallelGroup(
																Alignment.LEADING)
														.addComponent(
																panelStatus,
																GroupLayout.DEFAULT_SIZE,
																GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																panelManipulation,
																GroupLayout.DEFAULT_SIZE,
																426,
																Short.MAX_VALUE))
										.addGap(13)));
		informationPanelLayout.setVerticalGroup(informationPanelLayout
				.createParallelGroup(Alignment.LEADING).addGroup(
						informationPanelLayout
								.createSequentialGroup()
								.addGap(22)
								.addComponent(panelStatus,
										GroupLayout.PREFERRED_SIZE, 153,
										Short.MAX_VALUE)
								.addGap(18)
								.addComponent(panelManipulation,
										GroupLayout.DEFAULT_SIZE, 240,
										Short.MAX_VALUE).addContainerGap()));
		informationPanel.setLayout(informationPanelLayout);

		tPane.addTab("Information", informationPanel);

		collectionPanel.setBorder(javax.swing.BorderFactory
				.createEtchedBorder());

		panelCollected.setBorder(javax.swing.BorderFactory
				.createTitledBorder("Collected"));

		lblWindSpeed.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblWindSpeed.setText("Wind Speed");

		lblAirBlast.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblAirBlast.setText("Air blast");

		lblRainfall.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblRainfall.setText("Rainfall in 24h");

		lblAirMoisture.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblAirMoisture.setText("Air moisture");

		lblGroundMoisture.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblGroundMoisture.setText("Ground moisture");

		lblAirPressure.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblAirPressure.setText("Air pressure");

		lblWSValue.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblWSValue.setForeground(new java.awt.Color(255, 0, 0));
		lblWSValue.setText("200");

		lblABValue.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblABValue.setForeground(new java.awt.Color(255, 0, 0));
		lblABValue.setText("200");
		lblABValue.setName(""); // NOI18N

		lblRainfallValue.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblRainfallValue.setForeground(new java.awt.Color(255, 0, 0));
		lblRainfallValue.setText("200");

		lblAMValue.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblAMValue.setForeground(new java.awt.Color(255, 0, 0));
		lblAMValue.setText("200");
		lblAMValue.setName(""); // NOI18N

		lblGMValue.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblGMValue.setForeground(new java.awt.Color(255, 0, 0));
		lblGMValue.setText("200");

		lblAPValue.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblAPValue.setForeground(new java.awt.Color(255, 0, 0));
		lblAPValue.setText("200");

		lblWSUnit.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblWSUnit.setText("km/h");

		lblABUnit.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblABUnit.setText("m3");

		lblUnitAB.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblUnitAB.setText("mm");

		lblAMUnit.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblAMUnit.setText("ktm");

		lblGMUnit.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblGMUnit.setText("kmt");

		lblAPUnit.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblAPUnit.setText("atm");

		lblABStatus.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblABStatus.setText("Good");

		lblWSStatus.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblWSStatus.setText("Good");

		lblAPStatus.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblAPStatus.setText("Good");

		lblRainfallStatus.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblRainfallStatus.setText("Good");

		lblAMStatus.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblAMStatus.setText("Good");

		lblGMStatus.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		lblGMStatus.setText("Good");

		lblDateTime.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
		lblDateTime.setText("24/10/2014");

		javax.swing.GroupLayout panelCollectedLayout = new javax.swing.GroupLayout(
				panelCollected);
		panelCollected.setLayout(panelCollectedLayout);
		panelCollectedLayout
				.setHorizontalGroup(panelCollectedLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								panelCollectedLayout
										.createSequentialGroup()
										.addGroup(
												panelCollectedLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addGroup(
																panelCollectedLayout
																		.createSequentialGroup()
																		.addGap(38,
																				38,
																				38)
																		.addGroup(
																				panelCollectedLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								lblAirPressure,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								lblGroundMoisture,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								lblAirMoisture,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								lblRainfall,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								lblAirBlast,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								lblWindSpeed,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE))
																		.addGap(67,
																				67,
																				67)
																		.addGroup(
																				panelCollectedLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								lblWSValue,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								lblABValue,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								lblRainfallValue,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								lblAMValue,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								lblGMValue,
																								javax.swing.GroupLayout.Alignment.TRAILING,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								lblAPValue,
																								javax.swing.GroupLayout.Alignment.TRAILING,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE))
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addGroup(
																				panelCollectedLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addGroup(
																								panelCollectedLayout
																										.createSequentialGroup()
																										.addGroup(
																												panelCollectedLayout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.TRAILING)
																														.addComponent(
																																lblABUnit,
																																javax.swing.GroupLayout.Alignment.LEADING,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE)
																														.addComponent(
																																lblUnitAB,
																																javax.swing.GroupLayout.Alignment.LEADING,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE)
																														.addComponent(
																																lblAMUnit,
																																javax.swing.GroupLayout.Alignment.LEADING,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE)
																														.addComponent(
																																lblGMUnit,
																																javax.swing.GroupLayout.Alignment.LEADING,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE)
																														.addComponent(
																																lblAPUnit,
																																javax.swing.GroupLayout.Alignment.LEADING,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE))
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))
																						.addGroup(
																								panelCollectedLayout
																										.createSequentialGroup()
																										.addComponent(
																												lblWSUnit,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addGap(2,
																												2,
																												2)))
																		.addGroup(
																				panelCollectedLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addComponent(
																								lblABStatus,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								javax.swing.GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addGroup(
																								panelCollectedLayout
																										.createSequentialGroup()
																										.addGroup(
																												panelCollectedLayout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.LEADING)
																														.addComponent(
																																lblAPStatus,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE)
																														.addComponent(
																																lblGMStatus,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE)
																														.addComponent(
																																lblRainfallStatus,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE)
																														.addComponent(
																																lblWSStatus,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE)
																														.addComponent(
																																lblAMStatus,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																javax.swing.GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE))
																										.addGap(17,
																												17,
																												17))))
														.addGroup(
																panelCollectedLayout
																		.createSequentialGroup()
																		.addGap(311,
																				311,
																				311)
																		.addComponent(
																				lblDateTime,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addGap(17,
																				17,
																				17)))
										.addGap(0, 0, 0)));
		panelCollectedLayout
				.setVerticalGroup(panelCollectedLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								panelCollectedLayout
										.createSequentialGroup()
										.addGap(27, 27, 27)
										.addGroup(
												panelCollectedLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																lblWindSpeed,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblWSValue,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblWSUnit,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblWSStatus,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addGap(30, 30, 30)
										.addGroup(
												panelCollectedLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																lblAirBlast,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblABValue,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblABUnit,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblABStatus,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addGap(31, 31, 31)
										.addGroup(
												panelCollectedLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																lblRainfall,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblRainfallValue,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblUnitAB,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblRainfallStatus,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addGap(38, 38, 38)
										.addGroup(
												panelCollectedLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																lblAirMoisture,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblAMValue,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblAMUnit,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblAMStatus,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addGap(34, 34, 34)
										.addGroup(
												panelCollectedLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																lblGroundMoisture,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblGMValue,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblGMUnit,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblGMStatus,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addGap(26, 26, 26)
										.addGroup(
												panelCollectedLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																lblAirPressure,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblAPValue,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblAPUnit,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																lblAPStatus,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addGap(31, 31, 31)
										.addComponent(
												lblDateTime,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addGap(31, 31, 31)));

		javax.swing.GroupLayout collectionPanelLayout = new javax.swing.GroupLayout(
				collectionPanel);
		collectionPanel.setLayout(collectionPanelLayout);
		collectionPanelLayout.setHorizontalGroup(collectionPanelLayout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						collectionPanelLayout
								.createSequentialGroup()
								.addGap(27, 27, 27)
								.addComponent(panelCollected,
										javax.swing.GroupLayout.DEFAULT_SIZE,
										javax.swing.GroupLayout.DEFAULT_SIZE,
										Short.MAX_VALUE).addGap(21, 21, 21)));
		collectionPanelLayout.setVerticalGroup(collectionPanelLayout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						collectionPanelLayout
								.createSequentialGroup()
								.addGap(24, 24, 24)
								.addComponent(panelCollected,
										javax.swing.GroupLayout.DEFAULT_SIZE,
										javax.swing.GroupLayout.DEFAULT_SIZE,
										Short.MAX_VALUE).addContainerGap()));

		tPane.addTab("Collection", collectionPanel);

		panelReport.setBorder(javax.swing.BorderFactory.createEtchedBorder());

		panelSubReport.setBorder(javax.swing.BorderFactory
				.createTitledBorder("Report"));

		reportFieldStaff.setColumns(20);
		reportFieldStaff.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
		reportFieldStaff.setRows(5);
		scrollReportStaff.setViewportView(reportFieldStaff);

		buttonSend.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
		buttonSend.setText("SEND");

		scrollListReportResponseStaff.setViewportView(listReportResponse);

		reportReponseStaff.setColumns(20);
		reportReponseStaff.setFont(new java.awt.Font("Times New Roman", 1, 18)); // NOI18N
		reportReponseStaff.setRows(5);
		reportReponseStaff.setEditable(false);
		scrollReportResponseStaff.setViewportView(reportReponseStaff);

		JButton btnUnSolved = new JButton("UnSolved");
		btnUnSolved.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent mEvent) {
				// Neu list report response co chon gia tri thi set la unsolved
				if (listReportResponse.getSelectedIndex() != -1) {
					weatherSH.setSolved(listReportResponse.getSelectedIndex(),
							listReportResponse.getSelectedValue(), false);
					JOptionPane.showMessageDialog(null,
							"Set UNSOLVED successfully");
				} else {
					JOptionPane.showMessageDialog(null,
							"Please choose report to set");
				}
			}
		});

		btnSolved = new JButton("Solved");
		btnSolved.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent mEvent) {
				// Neu list report response co chon gia tri thi set la solved
				if (listReportResponse.getSelectedIndex() != -1) {
					weatherSH.setSolved(listReportResponse.getSelectedIndex(),
							listReportResponse.getSelectedValue(), true);
					JOptionPane.showMessageDialog(null,
							"Set SOLVED successfully");
				} else {
					JOptionPane.showMessageDialog(null,
							"Please choose report to set");
				}
			}
		});

		javax.swing.GroupLayout panelSubReportLayout = new javax.swing.GroupLayout(
				panelSubReport);
		panelSubReportLayout
				.setHorizontalGroup(panelSubReportLayout
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								panelSubReportLayout
										.createSequentialGroup()
										.addGap(26)
										.addGroup(
												panelSubReportLayout
														.createParallelGroup(
																Alignment.TRAILING)
														.addGroup(
																panelSubReportLayout
																		.createSequentialGroup()
																		.addComponent(
																				scrollReportStaff,
																				GroupLayout.DEFAULT_SIZE,
																				264,
																				Short.MAX_VALUE)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				buttonSend))
														.addGroup(
																panelSubReportLayout
																		.createSequentialGroup()
																		.addComponent(
																				scrollListReportResponseStaff,
																				GroupLayout.PREFERRED_SIZE,
																				92,
																				GroupLayout.PREFERRED_SIZE)
																		.addPreferredGap(
																				ComponentPlacement.RELATED,
																				GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addGroup(
																				panelSubReportLayout
																						.createParallelGroup(
																								Alignment.LEADING,
																								false)
																						.addComponent(
																								btnSolved,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnUnSolved,
																								GroupLayout.DEFAULT_SIZE,
																								86,
																								Short.MAX_VALUE))
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				scrollReportResponseStaff,
																				GroupLayout.PREFERRED_SIZE,
																				171,
																				GroupLayout.PREFERRED_SIZE)))
										.addContainerGap()));
		panelSubReportLayout
				.setVerticalGroup(panelSubReportLayout
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								panelSubReportLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												panelSubReportLayout
														.createParallelGroup(
																Alignment.LEADING)
														.addComponent(
																buttonSend,
																GroupLayout.PREFERRED_SIZE,
																57,
																GroupLayout.PREFERRED_SIZE)
														.addComponent(
																scrollReportStaff,
																GroupLayout.DEFAULT_SIZE,
																111,
																Short.MAX_VALUE))
										.addPreferredGap(
												ComponentPlacement.UNRELATED)
										.addGroup(
												panelSubReportLayout
														.createParallelGroup(
																Alignment.LEADING)
														.addComponent(
																scrollListReportResponseStaff,
																GroupLayout.PREFERRED_SIZE,
																0,
																Short.MAX_VALUE)
														.addGroup(
																panelSubReportLayout
																		.createParallelGroup(
																				Alignment.BASELINE)
																		.addComponent(
																				scrollReportResponseStaff,
																				GroupLayout.PREFERRED_SIZE,
																				126,
																				GroupLayout.PREFERRED_SIZE)
																		.addGroup(
																				panelSubReportLayout
																						.createSequentialGroup()
																						.addComponent(
																								btnSolved,
																								GroupLayout.PREFERRED_SIZE,
																								52,
																								GroupLayout.PREFERRED_SIZE)
																						.addGap(22)
																						.addComponent(
																								btnUnSolved,
																								GroupLayout.DEFAULT_SIZE,
																								52,
																								Short.MAX_VALUE))))
										.addContainerGap()));
		panelSubReport.setLayout(panelSubReportLayout);

		panelListDamaged.setBorder(javax.swing.BorderFactory
				.createTitledBorder("List Damaged"));

		listDamaged.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		scrollPanelListDamaged.setViewportView(listDamaged);

		javax.swing.GroupLayout panelListDamagedLayout = new javax.swing.GroupLayout(
				panelListDamaged);
		panelListDamaged.setLayout(panelListDamagedLayout);
		panelListDamagedLayout.setHorizontalGroup(panelListDamagedLayout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						panelListDamagedLayout.createSequentialGroup()
								.addGap(23, 23, 23)
								.addComponent(scrollPanelListDamaged)
								.addGap(33, 33, 33)));
		panelListDamagedLayout
				.setVerticalGroup(panelListDamagedLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								panelListDamagedLayout
										.createSequentialGroup()
										.addComponent(
												scrollPanelListDamaged,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												84, Short.MAX_VALUE)
										.addGap(12, 12, 12)));

		javax.swing.GroupLayout panelReportLayout = new javax.swing.GroupLayout(
				panelReport);
		panelReport.setLayout(panelReportLayout);
		panelReportLayout
				.setHorizontalGroup(panelReportLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								panelReportLayout
										.createSequentialGroup()
										.addGap(37, 37, 37)
										.addGroup(
												panelReportLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																panelListDamaged,
																javax.swing.GroupLayout.Alignment.LEADING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE)
														.addComponent(
																panelSubReport,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addGap(26, 26, 26)));
		panelReportLayout
				.setVerticalGroup(panelReportLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								panelReportLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												panelListDamaged,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												panelSubReport,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addGap(16, 16, 16)));

		tPane.addTab("Report", panelReport);

		reportStationPanel.setBorder(javax.swing.BorderFactory
				.createTitledBorder("Report of Station"));

		scrollListReport.setViewportView(listReport);
		reportFieldAR.setRows(5);
		reportFieldAR.setEditable(false);
		reportFieldAR.setLineWrap(true);
		reportFieldAR.setWrapStyleWord(true);
		scrollReportAR.setViewportView(reportFieldAR);

		reportResponseARPanel.setBorder(javax.swing.BorderFactory
				.createTitledBorder("Report response"));

		reportResponseAR.setColumns(20);
		reportResponseAR.setRows(5);
		scrollReportResponse.setViewportView(reportResponseAR);

		sendButton.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		sendButton.setText("SEND");

		javax.swing.GroupLayout reportResponseARPanelLayout = new javax.swing.GroupLayout(
				reportResponseARPanel);
		reportResponseARPanel.setLayout(reportResponseARPanelLayout);
		reportResponseARPanelLayout
				.setHorizontalGroup(reportResponseARPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								reportResponseARPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												scrollReportResponse,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												280, Short.MAX_VALUE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												sendButton,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addGap(20, 20, 20)));
		reportResponseARPanelLayout
				.setVerticalGroup(reportResponseARPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								reportResponseARPanelLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												reportResponseARPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																scrollReportResponse,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																149,
																Short.MAX_VALUE)
														.addComponent(
																sendButton,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																Short.MAX_VALUE))
										.addContainerGap()));

		javax.swing.GroupLayout reportStationPanelLayout = new javax.swing.GroupLayout(
				reportStationPanel);
		reportStationPanelLayout.setHorizontalGroup(reportStationPanelLayout
				.createParallelGroup(Alignment.LEADING)
				.addGroup(
						Alignment.TRAILING,
						reportStationPanelLayout
								.createSequentialGroup()
								.addGap(29)
								.addComponent(scrollListReport,
										GroupLayout.DEFAULT_SIZE, 105,
										Short.MAX_VALUE)
								.addGap(18)
								.addComponent(scrollReportAR,
										GroupLayout.PREFERRED_SIZE, 241,
										GroupLayout.PREFERRED_SIZE).addGap(30))
				.addGroup(
						reportStationPanelLayout
								.createSequentialGroup()
								.addContainerGap()
								.addComponent(reportResponseARPanel,
										GroupLayout.DEFAULT_SIZE, 403,
										Short.MAX_VALUE).addContainerGap()));
		reportStationPanelLayout
				.setVerticalGroup(reportStationPanelLayout
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								reportStationPanelLayout
										.createSequentialGroup()
										.addGroup(
												reportStationPanelLayout
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																reportStationPanelLayout
																		.createSequentialGroup()
																		.addGap(22)
																		.addComponent(
																				scrollReportAR))
														.addGroup(
																reportStationPanelLayout
																		.createSequentialGroup()
																		.addGap(24)
																		.addComponent(
																				scrollListReport,
																				GroupLayout.DEFAULT_SIZE,
																				167,
																				Short.MAX_VALUE)))
										.addPreferredGap(
												ComponentPlacement.RELATED)
										.addComponent(reportResponseARPanel,
												GroupLayout.DEFAULT_SIZE, 193,
												Short.MAX_VALUE)));
		reportStationPanel.setLayout(reportStationPanelLayout);

		javax.swing.GroupLayout reportARPanelLayout = new javax.swing.GroupLayout(
				reportARPanel);
		reportARPanelLayout.setHorizontalGroup(reportARPanelLayout
				.createParallelGroup(Alignment.LEADING).addGroup(
						reportARPanelLayout
								.createSequentialGroup()
								.addGap(20)
								.addComponent(reportStationPanel,
										GroupLayout.DEFAULT_SIZE, 424,
										Short.MAX_VALUE).addGap(21)));
		reportARPanelLayout.setVerticalGroup(reportARPanelLayout
				.createParallelGroup(Alignment.LEADING).addGroup(
						reportARPanelLayout
								.createSequentialGroup()
								.addGap(16)
								.addComponent(reportStationPanel,
										GroupLayout.DEFAULT_SIZE, 416,
										Short.MAX_VALUE).addGap(16)));
		reportARPanel.setLayout(reportARPanelLayout);

		tPane.addTab("Report Admin Role", reportARPanel);

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				layout.createSequentialGroup().addGap(24, 24, 24)
						.addComponent(tPane).addGap(30, 30, 30)));
		layout.setVerticalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				layout.createSequentialGroup().addGap(14, 14, 14)
						.addComponent(tPane).addGap(22, 22, 22)));

		pack();

	}// </editor-fold>//GEN-END:initComponents

	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {

			public void run() {
				WeatherStationForm a = new WeatherStationForm("WS01");
				a.setVisible(true);
				/* a.doTask(); */

			}
		});
	}

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JButton buttonCharge;
	private javax.swing.JButton buttonRestart;
	private javax.swing.JButton buttonSend;
	private javax.swing.JButton buttonShutdown;
	private javax.swing.JLabel lblOnOffValue;
	private javax.swing.JButton buttonStart;
	private javax.swing.JPanel collectionPanel;
	private javax.swing.JPanel informationPanel;
	private javax.swing.JLabel lblABStatus;
	private javax.swing.JLabel lblABUnit;
	private javax.swing.JLabel lblABValue;
	private javax.swing.JLabel lblAMStatus;
	private javax.swing.JLabel lblAMUnit;
	private javax.swing.JLabel lblAMValue;
	private javax.swing.JLabel lblAPStatus;
	private javax.swing.JLabel lblAPUnit;
	private javax.swing.JLabel lblAPValue;
	private javax.swing.JLabel lblAirBlast;
	private javax.swing.JLabel lblAirMoisture;
	private javax.swing.JLabel lblAirPressure;
	private javax.swing.JLabel lblBattery;
	private javax.swing.JLabel lblBatteryImage;
	private javax.swing.JLabel lblBatteryInPercentage;
	private javax.swing.JLabel lblBatteryStatus;
	private javax.swing.JLabel lblChargePin;
	private javax.swing.JLabel lblConnection;
	private javax.swing.JLabel lblConnectionStatus;
	private javax.swing.JLabel lblDateTime;
	private javax.swing.JLabel lblGMStatus;
	private javax.swing.JLabel lblGMUnit;
	private javax.swing.JLabel lblGMValue;
	private javax.swing.JLabel lblGroundMoisture;
	private javax.swing.JLabel lblOnOff;
	private javax.swing.JLabel lblRainfall;
	private javax.swing.JLabel lblRainfallStatus;
	private javax.swing.JLabel lblRainfallValue;
	private javax.swing.JLabel lblRestart;
	private javax.swing.JLabel lblShutdown;
	private javax.swing.JLabel lblStart;
	private javax.swing.JLabel lblUnitAB;
	private javax.swing.JLabel lblWSStatus;
	private javax.swing.JLabel lblWSUnit;
	private javax.swing.JLabel lblWSValue;
	private javax.swing.JLabel lblWindSpeed;
	private javax.swing.JList<String> listDamaged;
	private javax.swing.JList<String> listReport;
	private javax.swing.JList<String> listReportResponse;
	private javax.swing.JPanel panelCollected;
	private javax.swing.JPanel panelListDamaged;
	private javax.swing.JPanel panelManipulation;
	private javax.swing.JPanel panelReport;
	private javax.swing.JPanel panelStatus;
	private javax.swing.JPanel panelSubReport;
	private javax.swing.JPanel reportARPanel;
	private javax.swing.JTextArea reportFieldAR;
	private javax.swing.JTextArea reportFieldStaff;
	private javax.swing.JTextArea reportReponseStaff;
	private javax.swing.JTextArea reportResponseAR;
	private javax.swing.JPanel reportResponseARPanel;
	private javax.swing.JPanel reportStationPanel;
	private javax.swing.JScrollPane scrollListReport;
	private javax.swing.JScrollPane scrollListReportResponseStaff;
	private javax.swing.JScrollPane scrollPanelListDamaged;
	private javax.swing.JScrollPane scrollReportAR;
	private javax.swing.JScrollPane scrollReportResponse;
	private javax.swing.JScrollPane scrollReportResponseStaff;
	private javax.swing.JScrollPane scrollReportStaff;
	private javax.swing.JButton sendButton;
	private javax.swing.JTabbedPane tPane;
	private DefaultListModel<String> dlmReport;

	private WeatherStationHandling weatherSH = null;
	private Timer timer = null;
	private Timer timer2 = null;
	private JButton btnSolved;

	public Timer getTimer2() {
		return timer2;
	}

	public void setTimer2(Timer timer2) {
		this.timer2 = timer2;
	}

	public WeatherStationHandling getWeatherSH() {
		return weatherSH;
	}

	public void setWeatherSH(WeatherStationHandling weatherSH) {
		this.weatherSH = weatherSH;
	}

	public Timer getTimer() {
		return timer;
	}

	public void setTimer(Timer timer) {
		this.timer = timer;
	}
}
